﻿<%@ Page Language="C#" MasterPageFile="../../MasterPage.Master" AutoEventWireup="true" CodeBehind="ICM_Dispenses.aspx.cs" Inherits="KPIS.GERP.GIMS.APP.APP_UI.Form.ICM_Dispenses" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<%@ Register TagPrefix="custom" Namespace="KPIS.Customs.UI" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowDbClick(sender, eventArgs) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = eventArgs.getDataKeyValue("Seq");
                $find("<%= RadManager1.ClientID %>").ajaxRequest(hiddenElement.value);
            }

            function SeqClick(seq) {
                var hiddenElement = document.getElementById("<%= hdSeq.ClientID %>");
                hiddenElement.value = seq;
                radopen('../Edit_Form/ICM_Dispense.aspx?Seq=' + seq, 'WindowDetail');
            }

            function onTextChange(sender) {
                if (sender.get_value() == "") {
                    sender.set_text("");
                }
            }

            function onTabSelecting(sender, args) {
                if (args.get_tab().get_pageViewID()) {
                    args.get_tab().set_postBack(false);
                }
            }

            function hideTooltip(sender) {
                var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
                if (tooltip) {
                    tooltip.hide();
                }
            }

            function closeRadWindow(sender, args) {
                $find("<%= RadManager1.ClientID %>").ajaxRequest('CloseWindow');
            }

            function ExpandPersonal(sender, Args) {
                if (!sender._loaded) {
                    $find("<%=RadAjaxPanel1.ClientID %>").ajaxRequest();
                    sender._loaded = true;
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" BackgroundPosition="None" Skin="Outlook">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager runat="server" ID="RadManager1" OnAjaxRequest="RadManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="panelData">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panelCommand" />
                    <telerik:AjaxUpdatedControl ControlID="panelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="panelCommand">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panelCommand" />
                    <telerik:AjaxUpdatedControl ControlID="panelData" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnUser">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="btnUser"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="panelData" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    
    <asp:Panel ID="panelHidden" runat="server">
        <asp:HiddenField ID="hdSeq" runat="server" Value="" />
    </asp:Panel>
    
    <telerik:RadSplitter id="RadSplitter1" runat="server" height="460" width="1000" Skin="Office2007">
        <telerik:RadPane id="LeftPane" runat="server" width="22" Scrolling="None" Locked="true">
            <telerik:RadSlidingZone id="SlidingZone1" runat="server" width="22" ClickToOpen="true">
                <telerik:RadSlidingPane id="PanePersonal" title="ข้อมูลส่วนตัว" runat="server" width="265" IconUrl="../Image/General/user.gif" EnableDock="false" OnClientBeforeExpand="ExpandPersonal">
                    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" OnAjaxRequest="OnAjaxRequest">
                    </telerik:RadAjaxPanel>
                </telerik:RadSlidingPane>
            </telerik:RadSlidingZone>
        </telerik:RadPane>
        <telerik:RadSplitBar id="RadSplitBar1" runat="server"></telerik:RadSplitBar>
        <telerik:RadPane id="PaneData" runat="server" Scrolling="None">
            <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                    <td>
                        <asp:Panel ID="panelCommand" runat="server">
                            <div class="bigModulePaneFull">
                                <div class="bigModuleBottomPaneFull">
                                    <table cellpadding="0" cellspacing="0">
                                        <tr class="command-list" width="100%">
                                            <td class="command-item" style="border: none">
                                                <asp:LinkButton ID="AddNew" runat="server" CssClass="LinkButton" OnClientClick="javascript:radopen('../Edit_Form/ICM_Dispense.aspx', 'WindowDetail');">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/AddRecord.gif" />&nbsp;&nbsp;เพิ่มข้อมูลใหม่
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item">
                                                <asp:LinkButton ID="Delete" runat="server" CssClass="LinkButton" OnClientClick="javascript:return confirm('ยืนยันการลบข้อมูลที่เลือก')" OnClick="Delete_Click">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Delete.gif" />&nbsp;&nbsp;ลบข้อมูล
                                                </asp:LinkButton>
                                            </td>
                                            <td class="command-item" align="right">
                                                <asp:LinkButton ID="Help" runat="server" CssClass="LinkButton" Visible="false" CausesValidation="false">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Tree/help3.gif" />&nbsp;&nbsp;ช่วยเหลือ
                                                </asp:LinkButton>
                                            </td>
                                            <%--<td class="command-item" align="right">
                                                <asp:LinkButton ID="Recycle" runat="server" CssClass="LinkButton" Visible="true" 
                                                    OnClientClick="javascript:radopen('../Delete_Form/ICM_Master_Resource_Type.aspx', 'WindowDelete');">
                                                    <img style="border:0px;vertical-align:middle;" alt="" src="../Image/Grid/Refresh.gif" width="14" height="14"/>&nbsp;&nbsp;กู้ข้อมูล
                                                </asp:LinkButton>
                                            </td>--%>
                                        </tr>
                                    </table>
                                </div>
                            </div>    
                            <telerik:RadToolTip runat="server" ID="RadToolTip1" Width="400px" Height="70px" TargetControlID="Help" ShowEvent="OnClick"
                                IsClientID="false" Animation="Fade" HideEvent="LeaveToolTip" Position="BottomCenter" Skin="Outlook">
                                <table width="100%">
                                    <tr class="table-outlook-header">
                                        <td>
                                            <asp:Label ID="lblTipHeader" runat="server" Text="ความสำคัญ" Font-Size="Small" ForeColor="White" Font-Bold="true"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Detail" runat="server" Font-Size="Small" 
                                            Text="<b>จำหน่ายพัสดุ</b> ใช้ประกอบกับตรวจสอบพัสดุ เพื่อใช้ในการตรวจสอบว่าพัสดุที่นำออกจากระบบนั้น ได้ถูกจำหน่ายออกจากระบบอย่างไร">
                                            </asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </telerik:RadToolTip>    
                        </asp:Panel>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Panel ID="panelData" runat="server">
                            <div class="bigModulePaneFull">
                                <div class="bigModuleBottomPaneFull">
                                    <asp:Panel ID="panelHeaderList" runat="server">
                                        <div class="header-grid">
                                            <asp:Label ID="lblHeaderList" runat="server" Text="ประเภทการจำหน่าย"></asp:Label>
                                        </div>
                                    </asp:Panel>
                                    <asp:Panel CssClass="panelList" runat="server" ID="panelList" ScrollBars="Auto">                                        
                                    </asp:Panel>
                                    <asp:Panel CssClass="panelGrid" ID="panelGrid" runat="server" ScrollBars="Auto" Visible="true" > 
                                        <div align="center">                                   
                                        <telerik:RadGrid ID="DataGrid" 
                                            runat="server" AllowFilteringByColumn="true" 
                                            AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True"
                                            AutoGenerateColumns="False" EnableAJAX="True" PageSize="8"
                                            GridLines="None" ShowStatusBar="false" Skin="Outlook" 
                                            Width="95%" Height="330px"
                                            OnItemCommand="DataGrid_ItemCommand"
                                            align ="left" >
                                            <MasterTableView AllowMultiColumnSorting="True" 
                                                CellSpacing="-1" GroupLoadMode="Client"
                                                ShowGroupFooter="true" NoMasterRecordsText="< ไม่มีข้อมูล >" 
                                                GroupsDefaultExpanded="true">
                                            <RowIndicatorColumn>
                                                <HeaderStyle Width="20px" />
                                            </RowIndicatorColumn>
                                            <ExpandCollapseColumn>
                                                <HeaderStyle Width="20px" />
                                            </ExpandCollapseColumn>
                                            <Columns>   
                                                <telerik:GridBoundColumn DataField="dispense_seq" HeaderStyle-Width="155px"
                                                    UniqueName="dispense_seq"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="dispense_date" HeaderStyle-Width="130px"
                                                    HeaderText="วันที่จำหน่ายพัสดุ" UniqueName="dispense_date" DataFormatString = "{0:D}"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn DataField="asset_code" HeaderText="รหัสพัสดุที่ทำการจำหน่าย" ShowFilterIcon="false" HeaderStyle-Font-Bold="false"
                                                        HeaderStyle-HorizontalAlign="Center" FilterControlWidth="100%" AutoPostBackOnFilter="true" AllowFiltering = "true" UniqueName="asset_code" HeaderStyle-Width="140px">
                                                        <ItemTemplate >                                                                                                                           
                                                                <asp:LinkButton ID="tgcAssetCode" runat="server" Text='<%# Eval("asset_code") %>' 
                                                                OnClientClick='<%# string.Format("return SeqClick(\"{0}\");", Eval("dispense_seq")) %>'  > 
                                                                </asp:LinkButton>
                                                        </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridBoundColumn DataField="dispense_desc" 
                                                    HeaderText="รายการจำหน่ายพัสดุ" UniqueName="dispense_desc"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="destination_location" HeaderStyle-Width="150px"
                                                    HeaderText="ตัดจำหน่ายไปยัง" UniqueName="destination_location"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="dispense_type_name" HeaderStyle-Width="150px"
                                                    HeaderText="ประเภทการตัดจำหน่าย" UniqueName="dispense_type_name"
                                                    FilterControlWidth="100%" AutoPostBackOnFilter="true"
                                                    CurrentFilterFunction="Contains" ShowFilterIcon="false" 
                                                    HeaderStyle-Font-Bold="false" HeaderStyle-HorizontalAlign="Center">
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <PagerStyle Mode="NumericPages" AlwaysVisible="true" 
                                                FirstPageToolTip="กลับหน้าแรก" LastPageToolTip="ไปหน้าสุดท้าย" 
                                                NextPagesToolTip="หน้าถัดไป" NextPageToolTip="หน้าถัดไป" 
                                                PrevPagesToolTip="ย้อนกลับ" PrevPageToolTip="ย้อนกลับ" />
                                            </MasterTableView>
                                            <GroupingSettings GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;&nbsp;" 
                                                GroupContinuedFormatString="" GroupContinuesFormatString="" 
                                                GroupSplitFormat="" />
                                            <ClientSettings EnableRowHoverStyle="True">
                                                <Selecting AllowRowSelect="true" />
                                                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                                            </ClientSettings>
                                            <ClientSettings EnableRowHoverStyle="true" >
                                                <Selecting AllowRowSelect="True" />
                                                <ClientEvents OnRowDblClick="RowDbClick" />
                                            </ClientSettings>
                                      </telerik:RadGrid>
                                        </div>
                                    </asp:Panel>
                                </div>
                            </div>
                        </asp:Panel>
                    </td>
                </tr>
            </table>
        </telerik:RadPane>
    </telerik:RadSplitter>
    <telerik:RadWindowManager ID="RadWindowManager1" ShowContentDuringLoad="false" VisibleStatusbar="false" ReloadOnShow="true" 
    runat="server" Skin="Vista" Modal="true" KeepInScreenBounds="true" Style="z-index: 7001">
        <Windows>
            <telerik:RadWindow ID="WindowDetail" runat="server" Width="1000px" Height="550px" Behaviors="Default" OnClientClose="closeRadWindow">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>  
</asp:Content>